#coding=utf-8
from strategy import *
from stutils import *
set_django_environ()
from stdj.stock.models import *

name = 'hptop_20'
if __name__ == '__main__':
    con = get_con()    
    eds = ['2007-12-03',
 '2007-12-04',
 '2007-12-05',
 '2007-12-06',
 '2007-12-07',
 '2007-12-10',
 '2007-12-11',
 '2007-12-12',
 '2007-12-13',
 '2007-12-14',
 '2007-12-17',
 '2007-12-18',
 '2007-12-19',
 '2007-12-20',
 '2007-12-21',
 '2007-12-24',
 '2007-12-25',
 '2007-12-26',
 '2007-12-27',
 '2007-12-28',
 '2008-01-02',
 '2008-01-03',
 '2008-01-04',
 '2008-01-07',
 '2008-01-08',
 '2008-01-09',
 '2008-01-10',
 '2008-01-11',
 '2008-01-14']
    
    for i in range(len(eds)-1):
        x = eds[i]; y = eds[i+1]
        print y
        cs_hp = set(get_hp(con, x,20))
        cs_top = set(get_top(con, y,20))
        
        cs = cs_hp.intersection(cs_top)
        
        for c in cs:
            s = Share.objects.get(code=c)
            e = s.exday_set.get(date=y)
            
            selected2db(con, e, name)
            